package com.patelski.magic.model;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;

import org.hibernate.validator.Length;
import org.hibernate.validator.NotNull;

@Entity
@Table(name = "EDITION_CATEGORIES")
public class EditionCategorie implements java.io.Serializable {

	/**
     * 
     */
    private static final long serialVersionUID = -4178650267756913733L;
	private String id;
	private String name;
	private String description;
	private List<Edition> editions;

	public EditionCategorie() {
	}

	public EditionCategorie(String name) {
		this.name = name;
	}

	public EditionCategorie(String id, String name) {
		this(name);
		this.id = id;
	}

	@Id
	@Column(name = "ID", unique = true, nullable = false, length = 4)
	@Length(max = 4)
	public String getId() {
		return this.id;
	}

	public void setId(String id) {
		this.id = id;
	}

	@Column(name = "NAME", nullable = false, length = 45)
	@NotNull
	@Length(max = 45)
	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}


	@OneToMany(fetch = FetchType.LAZY, mappedBy = "editionCategorie")
	@OrderBy("sortOrder desc")
	public List<Edition> getEditions() {
		return this.editions;
	}

	public void setEditions(List<Edition> theEditions) {
		this.editions = theEditions;
	}

	@Column(name = "DESCRIPTION", columnDefinition = "text")
	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

}
